#!/usr/bin/env python
# -*- coding:utf-8 -*-

# 第二次作业题

# 1有变量name = "aleX leNb "完成如下操作：
#移除 name 变量对应的值两边的空格,并输出处理结果
""""
name = "aleX leNb "
name_new =name.strip()
print('--->',name_new,'<---')
"""
# 判断 name 变量是否以 "al" 开头,并输出结果（用切片）#有变量name = "aleX leNb
"""
name = input("请输入你的姓名：")
name1 = name[0:2]     #切片
if name1 =="al" :
    print('true')
"""


# 判断name变量是否以"Nb"结尾,并输出结果（用切片）
"""
# name = input("请输入你的姓名：")
# name1 = name[-2:]     #切片
# if name1 =="Nb" :
#     print('true')
"""


# name 变量对应的值中的 所有的"l" 替换为 "p",并输出结果.
"""
name = "aleX leNb "
name_new = name.replace('l','p')
print(name_new)
"""


# 将 name 变量对应的值根据 所有的"l" 分割,并输出结果
"""
name = "aleX leNb "
name_new = name.split('l')
print(name_new)
"""

# 将 name 变量对应的值变大写,并输出结果
"""
name = "aleX leNb "
name_new = name.upper()
print(name_new)
"""


# 将 name 变量对应的值变小写,并输出结果
"""
name = "aleX leNb "
name_new = name.lower()
print(name_new)
"""

# 请输出 name 变量对应的值的第 2 个字符?
"""
name = "aleX leNb "
name_new = name[1:2]
print(name_new)
"""


# 请输出 name 变量对应的值的前 3 个字符?
"""
name = "aleX leNb "
name_new = name[0:3]
print(name_new)
"""

# 请输出 name 变量对应的值的后 2 个字符?
"""
name = "aleX leNb "
name_new = name[-3:-1]
print(name_new)
"""


# 2 有字符串s = "123a4b5c"
# 通过对s切片形成新的字符串 "123"
"""
s="123a4b5c"
s=s[0:3]
print(s)
"""

# 通过对s切片形成新的字符串 "a4b"
"""
s="123a4b5c"
s=s[3:6]
print(s)
"""

# 通过对s切片形成字符串s5,s5 = "c"
"""
s="123a4b5c"
s=s[-1]
print(s)
"""
# 通过对s切片形成字符串s6,s6 = "ba2"
"""
s="123a4b5c"
s=s[-3::-2]
print(s)
"""

#3.使用while循环字符串 s="asdfer" 中每个元素。
"""
s="asdfer"
s_len = len(s)
count=0
while count<=s_len-1:
    result=s[count]
    print(result)
    count +=1
"""
#4.使用while循环对s="321"进行循环，打印的内容依次是：，倒计时3秒"倒计时2秒"，"倒计时1秒"，"出发！"。
"""
s="321"
s_len=len(s)
count=0
while count <= s_len-1:
    time =s[count]
    content="倒计时%s秒"%(time,)
    print(content)
    count +=1
print('出发！')
"""
# 5整数加法计算器(两个数相加)：
#如：content = input("请输入内容:") 用户输入：5+9或5+ 9或5 + 9（含空白），然后进行分割转换最终进行整数的计算得到结果。
"""
content1 = input('请输入内容：')
content2=input('请输入内容：')
num1 = content1.strip()
num2 = content2.strip()
num1=int(num1)
num2=int(num2)
result=num1+num2
print(result)
"""
"""
content = input('请输入内容：')
content1 = content.split('+')
num1=content1[0]
num2=content1[1]
num1_new=num1.strip()
num2_new=num2.strip()
num1_new=int(num1_new)
num2_new=int(num2_new)
result=num1_new+num2_new
print(result)
"""

"""
#如：content = input("请输入内容：") # 如fhdal234slfh98769fjdla
# content = input('请输入内容:')
# content_new = content.isdigit()
# print(content_new)
content = input("请输入内容：")
content_len = len(content)
timer = 0
sum = 0
while timer <= content_len -1:
    if content[timer] == 'h':
        sum += 1
    timer += 1
print(sum)
"""


# 7 计算用户输入的内容中有几个 h 或 H 字符？
#如：content = input("请输入内容：") # 如fhdal234slfH9H769fjdla
"""
content = input('请输入内容：')
content_new = content.lower()
content_len = len(content)
# print(content_new)
sum = 0
count = 0
while count <=content_len-1:
    content1 = content_new[count]
    if content1 == 'h':
        sum = sum+1
    count = count+1
print(sum)

# content = input("请输入内容：")
# content_len = len(content)
# timer= 0
# sum = 0
# while timer <= content_len - 1 :
#     if content[timer]== 'h'or 'H':
#         sum += 1
#     timer += 1
# print(sum)
"""

#8 使用while循环分别正向和反向对字符串 message = "伤情最是晚凉天，憔悴厮人不堪言。" 进行打印
# message = "伤情最是晚凉天，憔悴斯人不堪言。"
# message_len = len(message)
# count=0
# while count<=message_len-1 :
#     message_new = message[count]
#     print(message_new)
#     count +=1
"""
message = "伤情最是晚凉天，憔悴斯人不堪言。"
message_len = len(message)
count=0
while count<=message_len-1 :
    count1=-count-1
    message_new = message[count1]
    print(message_new)
    count +=1
"""

# 9 获取用户输入的内容中 前4个字符中 有几个 A ？
#如：content = input("请输入内容：") # 如fAdal234slfH9H769fjdla
"""
content = input("请输入内容：")
content_new = content[0:4]
total = 0
count = 0
len_content =len(content_new)
while count <= len_content-1:
    text = content_new[count]
    if text == 'A':
        total =total+1
    count=count+1
print(total)
"""

# 11 获取用户两次输入的内容，并将所有的数据获取并进行相加，如：
"""
# 要求：
# 	将num1中的的所有数字找到并拼接起来：1232312
# 	将num2中的的所有数字找到并拼接起来：1218323
# 	然后将两个数字进行相加。
# """
# num1 = input("请输入：") # asdfd123sf2312
# num2 = input("请输入：") # a12dfd183sf23

num1 = input("请输入：")
num2 = input("请输入：")
len_num1 = len(num1)
len_num2 = len(num2)
count = 0
a=' '
b=" "
while count <= len_num1-1:
    num1_new = num1[count]
    flag =num1_new.isdigit()

    if flag == True:
        a = a + num1_new
    count=count+1
print(a)
count =0
while count <= len_num2-1:
    num2_new = num2[count]
    flag =num2_new.isdigit()

    if flag == True:
        b = b + num2_new
    count=count+1
print(b)
a=int(a)
b=int(b)
sum = a+b
print(sum)

